package com.juku2024.juku.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.juku2024.juku.R
import com.juku2024.juku.model.CarouselModel
import com.juku2024.juku.tools.ImageUtils
import com.youth.banner.adapter.BannerAdapter

class HomeBannerAdapter(data: ArrayList<CarouselModel>): BannerAdapter<CarouselModel, HomeBannerAdapter.BannerViewHolder>(data) {

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        return BannerViewHolder(LayoutInflater.from(parent?.context).inflate(R.layout.item_home_banner, parent, false))
    }

    override fun onBindView(holder: BannerViewHolder?, data: CarouselModel?, position: Int, size: Int) {
        ImageUtils.loadImageH(holder?.imageView, data?.pic)
        holder?.tvName?.text = data?.name
    }

    class BannerViewHolder(itemView: View): RecyclerView.ViewHolder(itemView){
        val imageView: ImageView = itemView.findViewById(R.id.iv_banner)
        val tvName: TextView = itemView.findViewById(R.id.tv_banner_name)
    }
}
